package com.digitaldreamers.framework;

import org.andengine.engine.Engine;

import com.digitaldreamers.framework.activity.GameActivity;

import android.content.Context;

public class BaseResourceManager {
	private static String ERROR_MESSAGE__SETUP_NOT_CALLED = "Please call setup() before calling this function";
	private static Object lockObj = new Object();
	private static BaseResourceManager instance;
	
	public Context mContext;
	public GameActivity mActivity;
	public Engine mEngine;
	public float mCameraWidth;
	public float mCameraHeight;
	public float mCameraScaleFactorX;
	public float mCameraScaleFactorY;
	
	public static void setup(Context context, GameActivity activity, Engine engine, float cameraWidth, float cameraHeight, float cameraScaleFactorX, float cameraScaleFactorY) {
		if(instance == null) {
			synchronized(lockObj) {
				if(instance == null) {
					instance = new BaseResourceManager();
				}
			}
		}
		instance.mContext = context;
		instance.mActivity = activity;
		instance.mEngine = engine;
		instance.mCameraWidth = cameraWidth;
		instance.mCameraHeight = cameraHeight;
		instance.mCameraScaleFactorX = cameraScaleFactorX;
		instance.mCameraScaleFactorY = cameraScaleFactorY;
	}
	
	public static BaseResourceManager getInstance() {
		if(instance == null) {
			throw new IllegalStateException(ERROR_MESSAGE__SETUP_NOT_CALLED);
		}
		return instance;
	}
	
	private BaseResourceManager() {
		
	}
}
